from api.db.db_models import Document
from api.db.services.common_service import CommonService
from api.db.db_models import DB


class DocumentService(CommonService):
    model = Document

    @classmethod
    @DB.connection_context()
    def get_thumbnails(cls, docids):
        fields = [cls.model.id, cls.model.kb_id, cls.model.thumbnail]
        return list(cls.model.select(
            *fields).where(cls.model.id.in_(docids)).dicts())